<!-- Author:Rain -->
<template>
  <div class="page-box" v-if="boss">
    <div class="user-center-wrap">
      <div class="user-info-wrap mb-20px">
        <div class="left">
          <div class="user-basic-info">
            <a
              @click="uploadProfile"
              :title="'id: ' + boss.id"
              target="_blank"
              class="user-avatar user-avatar-link inline-block cursor-pointer avatar"
              style="width: 90px; height: 90px"
              ><img :src="bascBossUrl + boss.profile" alt="小雨" class="user-avatar-image" />
              <div class="vip-icon-container"><!----></div>
            </a>
            <!-- 修改个人头像 -->
            <el-dialog
              v-model="ProfileDialogVisible"
              title="上传头像"
              width="500"
              align-center
              center
            >
              <el-upload
                class="avatar-uploader"
                action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"
                :show-file-list="false"
                :on-success="handleAvatarSuccess"
                :before-upload="beforeAvatarUpload"
              >
                <img v-if="imageUrl" :src="imageUrl" class="avatar" />
                <el-icon v-else class="avatar-uploader-icon">
                  <Plus />
                </el-icon>
              </el-upload>
              <template #footer>
                <div class="dialog-footer">
                  <el-button @click="ProfileDialogVisible = false">取消</el-button>
                  <el-button type="primary" @click="ProfileDialogVisible = false"> 提交 </el-button>
                </div>
              </template>
            </el-dialog>
            <div class="user-info-right">
              <div>
                <span class="name">{{ boss.realname }}</span>
                <span class="level">{{ boss.position }}</span>
                <span><el-button @click="editBoss" type="primary" :icon="Edit" circle /></span>
                <!---->
              </div>
            </div>
            <!-- 编辑个人信息 -->
            <el-dialog v-model="fullDialogVisible" title="编辑boss信息" width="600" align-center>
              <!-- 内容区 -->
              <div id="contentWrap">
                <el-form :model="form" label-width="auto" style="max-width: 600px">
                  <el-form-item label="昵称">
                    <el-input v-model="form.realname" />
                  </el-form-item>
                  <el-form-item label="职称">
                    <el-input v-model="form.position" />
                  </el-form-item>
                  <el-form-item label="电话">
                    <el-input v-model="form.phone" />
                  </el-form-item>
                  <el-form-item label="电子邮箱">
                    <el-input v-model="form.email" />
                  </el-form-item>
                  <div style="display: flex; justify-content: center">
                    <el-button type="primary" @click="onSubmit">修改</el-button>
                    <el-button>取消</el-button>
                  </div>
                </el-form>
              </div>
            </el-dialog>
          </div>
          <div class="basic-items">
            <!---->
            <el-tooltip
              class="box-item"
              :show-after="500"
              effect="dark"
              content="已认证"
              placement="bottom"
            >
              <div class="basic-item">
                <img
                  src=""
                  class="icon-name"
                />
                <span class="text">{{ boss.realname }}</span>
              </div>
            </el-tooltip>
            <el-tooltip
              class="box-item"
              :show-after="500"
              effect="dark"
              content="企业认证后可以发布岗位"
              placement="bottom"
            >
              <div
                id="Certification"
                @click="centerDialogVisible1 = true"
                class="basic-item"
                style="cursor: pointer; user-select: none"
              >
                <img
                  src=""
                  class="icon-school"
                />
                <span class="text">{{ boss.company }}</span>
              </div>
            </el-tooltip>
            <!---->
            <div
              @click="centerDialogVisible = true"
              class="basic-item"
              id="editPost"
              style="cursor: pointer; user-select: none"
            >
              <span class="text"
                ><el-icon>
                  <CreditCard size="20" /> </el-icon
                >个人名片</span
              >
            </div>
            <!---->

            <!-- 卡片弹出区 -->
            <!-- start -->
            <el-dialog v-model="centerDialogVisible" title="名片信息" width="600" align-center>
              <span class="card-tips">该名片信息用于您给人才发送名片时的设计</span>
              <div class="card-wrap">
                <!-- 这里面需要设计几个位置 -->
                <span class="card-name">{{ boss.realname }}</span>
                <span class="card-position card-inner-font">{{ boss.position }}</span>
                <span class="card-phone card-inner-font">{{ boss.phone }}</span>
                <span class="card-address card-inner-font">{{ boss.company }}</span>
                <span class="card-email card-inner-font">{{ boss.email }}</span>
              </div>
              <template #footer>
                <div class="dialog-footer">
                  <el-button @click="centerDialogVisible = false">编辑名片</el-button>
                </div>
              </template>
            </el-dialog>
            <!-- end -->
          </div>
        </div>
        <div class="right">
          <div>
            <div class="ext-items" v-if="boss.show">
              <div class="ext-item cursor-pointer">
                <span class="key">职位访问量</span>
                <span class="value">{{ boss.show.visits }}</span>
              </div>
              <div class="divide"></div>
              <div class="ext-item cursor-pointer">
                <span class="key">职位收藏量</span>
                <span class="value">{{ boss.show.collect }}</span>
              </div>
              <div class="divide"></div>
              <div class="ext-item cursor-pointer">
                <span class="key">发送offer量</span>
                <span class="value">{{ boss.show.offer }}</span>
              </div>
              <div class="divide"></div>
              <div class="ext-item cursor-pointer">
                <span class="key">目前职位量</span> <span class="value">{{ boss.show.positions }}</span>
              </div>
              <!---->
            </div>
          </div>
        </div>
      </div>
      <div class="bottom-content">
        <div class="left">
          <div class="card-panel mb-20px">
            <header class="header">
              <div class="header-wrap"><span class="title">数据总览</span></div>
            </header>
            <div class="content">
              <!-- 内容区 -->
            </div>
          </div>
        </div>
        <div class="right">
          <div class="card-panel">
            <!---->
            <div class="content" style="padding-bottom: 88px">
              <div class="title">最近访客</div>
              <div class="visitors">
                <div class="visitor-link">
                  <a href="/users/1848346" class target="_blank">
                    <div
                      class="flex flex-col justify-center items-center text-333 font-normal text-xs w-full text-center"
                    >
                      <a
                        title="id: 1848346"
                        target="_blank"
                        class="user-avatar user-avatar-link inline-block cursor-pointer mb-4px"
                        height="44"
                        style="width: 44px; height: 44px"
                        ><img
                          src="https://static-qiniu.lanqiao.cn/avatar/uid3795694-20240116-1705404820858?imageView2/1/w/90/h/90/"
                          alt="lanqiao9337524993"
                          class="user-avatar-image"
                        />
                        <div class="vip-icon-container"><!----></div>
                      </a>
                      <span class="name">来了</span> <span class="timestamp">3小时前</span>
                    </div>
                  </a>
                </div>
                <div class="visitor-link">
                  <a href="/users/2178679" class target="_blank">
                    <div
                      class="flex flex-col justify-center items-center text-333 font-normal text-xs w-full text-center"
                    >
                      <a
                        title="id: 2178679"
                        target="_blank"
                        class="user-avatar user-avatar-link inline-block cursor-pointer mb-4px"
                        height="44"
                        style="width: 44px; height: 44px"
                        ><img
                          src="https://static-qiniu.lanqiao.cn/avatar/uid3795694-20240116-1705404820858?imageView2/1/w/90/h/90/   "
                          alt="如意"
                          class="user-avatar-image"
                        />
                        <div class="vip-icon-container"><!----></div>
                      </a>
                      <span class="name">如意</span> <span class="timestamp">2024-03-14</span>
                    </div>
                  </a>
                </div>
                <div class="visitor-link">
                  <a href="/users/2674834" class target="_blank">
                    <div
                      class="flex flex-col justify-center items-center text-333 font-normal text-xs w-full text-center"
                    >
                      <a
                        title="id: 2674834"
                        target="_blank"
                        class="user-avatar user-avatar-link inline-block cursor-pointer mb-4px"
                        height="44"
                        style="width: 44px; height: 44px"
                        ><img
                          src="https://static-qiniu.lanqiao.cn/avatar/uid3795694-20240116-1705404820858?imageView2/1/w/90/h/90/"
                          alt="只因"
                          class="user-avatar-image"
                        />
                        <div class="vip-icon-container"><!----></div>
                      </a>
                      <span class="name">只因</span> <span class="timestamp">2024-03-12</span>
                    </div>
                  </a>
                </div>
                <div class="visitor-link">
                  <a href="/users/2934215" class target="_blank">
                    <div
                      class="flex flex-col justify-center items-center text-333 font-normal text-xs w-full text-center"
                    >
                      <a
                        title="id: 2934215"
                        target="_blank"
                        class="user-avatar user-avatar-link inline-block cursor-pointer mb-4px"
                        height="44"
                        style="width: 44px; height: 44px"
                        ><img
                          src="https://static-qiniu.lanqiao.cn/avatar/uid3795694-20240116-1705404820858?imageView2/1/w/90/h/90/"
                          alt="lanqiao1995211051"
                          class="user-avatar-image"
                        />
                        <div class="vip-icon-container"><!----></div>
                      </a>
                      <span class="name">说的话</span> <span class="timestamp">2024-03-12</span>
                    </div>
                  </a>
                </div>
                <div class="visitor-link">
                  <a href="/users/1949792" class target="_blank">
                    <div
                      class="flex flex-col justify-center items-center text-333 font-normal text-xs w-full text-center"
                    >
                      <a
                        title="id: 1949792"
                        target="_blank"
                        class="user-avatar user-avatar-link inline-block cursor-pointer mb-4px"
                        height="44"
                        style="width: 44px; height: 44px"
                        ><img
                          src="https://static-qiniu.lanqiao.cn/avatar/uid3795694-20240116-1705404820858?imageView2/1/w/90/h/90/"
                          alt="秃头小宝贝"
                          class="user-avatar-image"
                        />
                        <div class="vip-icon-container"><!----></div>
                      </a>
                      <span class="name">秃头小宝贝</span> <span class="timestamp">2024-03-12</span>
                    </div>
                  </a>
                </div>
                <div class="visitor-link">
                  <a href="/users/2688198" class target="_blank">
                    <div
                      class="flex flex-col justify-center items-center text-333 font-normal text-xs w-full text-center"
                    >
                      <a
                        title="id: 2688198"
                        target="_blank"
                        class="user-avatar user-avatar-link inline-block cursor-pointer mb-4px"
                        height="44"
                        style="width: 44px; height: 44px"
                        ><img
                          src="https://static-qiniu.lanqiao.cn/avatar/uid3795694-20240116-1705404820858?imageView2/1/w/90/h/90/"
                          alt="undefined"
                          class="user-avatar-image"
                        />
                        <div class="vip-icon-container">
                          <img
                            src="https://static.shiyanlou.com/lanqiao/frontend/dist/img/plus-vip-icon.746ffa6.png"
                            width="15.84px"
                            class="vip-icon"
                          />
                        </div>
                      </a>
                      <span class="name">undefined</span> <span class="timestamp">2024-03-12</span>
                    </div>
                  </a>
                </div>
                <div class="visitor-link">
                  <a href="/users/2664652" class target="_blank">
                    <div
                      class="flex flex-col justify-center items-center text-333 font-normal text-xs w-full text-center"
                    >
                      <a
                        title="id: 2664652"
                        target="_blank"
                        class="user-avatar user-avatar-link inline-block cursor-pointer mb-4px"
                        height="44"
                        style="width: 44px; height: 44px"
                        ><img
                          src="https://static-qiniu.lanqiao.cn/avatar/uid3795694-20240116-1705404820858?imageView2/1/w/90/h/90/"
                          alt="lanqiao4872311420"
                          class="user-avatar-image"
                        />
                        <div class="vip-icon-container"><!----></div>
                      </a>
                      <span class="name">是多少</span> <span class="timestamp">2024-03-12</span>
                    </div>
                  </a>
                </div>
                <div class="visitor-link">
                  <a href="/users/2622831" class target="_blank">
                    <div
                      class="flex flex-col justify-center items-center text-333 font-normal text-xs w-full text-center"
                    >
                      <a
                        title="id: 2622831"
                        target="_blank"
                        class="user-avatar user-avatar-link inline-block cursor-pointer mb-4px"
                        height="44"
                        style="width: 44px; height: 44px"
                        ><img
                          src="https://static-qiniu.lanqiao.cn/avatar/uid3795694-20240116-1705404820858?imageView2/1/w/90/h/90/"
                          alt="lanqiao0469961369"
                          class="user-avatar-image"
                        />
                        <div class="vip-icon-container"><!----></div>
                      </a>
                      <span class="name">非官方个</span> <span class="timestamp">2024-03-12</span>
                    </div>
                  </a>
                </div>
                <div class="visitor-link">
                  <a href="/users/2137583" class target="_blank">
                    <div
                      class="flex flex-col justify-center items-center text-333 font-normal text-xs w-full text-center"
                    >
                      <a
                        title="id: 2137583"
                        target="_blank"
                        class="user-avatar user-avatar-link inline-block cursor-pointer mb-4px"
                        height="44"
                        style="width: 44px; height: 44px"
                        ><img
                          src="https://static-qiniu.lanqiao.cn/avatar/uid3795694-20240116-1705404820858?imageView2/1/w/90/h/90/"
                          alt="lanqiao7959167943"
                          class="user-avatar-image"
                        />
                        <div class="vip-icon-container"><!----></div>
                      </a>
                      <span class="name">环境</span> <span class="timestamp">2024-03-11</span>
                    </div>
                  </a>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!---->
    </div>
  </div>
  <!-- 公司认证！！！ -->
  <el-dialog v-model="centerDialogVisible1" title="Warning" width="500" align-center>
    <span>Open the dialog from the center from the screen</span>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="centerDialogVisible1 = false">Cancel</el-button>
        <el-button type="primary" @click="centerDialogVisible1 = false"> Confirm </el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup lang="ts">
// 获取boss信息
import { useBossStore } from '@/store/modules/boss'
const centerDialogVisible = ref(false)
const fullDialogVisible = ref(false)
const bossStore = useBossStore()
const { boss, updateBossInfo } = bossStore
const bascBossUrl = ref('http://localhost:8080/api/images/companyLogo/')
import { Edit, CreditCard, Plus } from '@element-plus/icons-vue'

function editBoss() {
  fullDialogVisible.value = true
}
const ProfileDialogVisible = ref(false)
function uploadProfile() {
  ProfileDialogVisible.value = true
}

import type { UploadProps } from 'element-plus'
const imageUrl = ref('')

const handleAvatarSuccess: UploadProps['onSuccess'] = (response, uploadFile) => {
  imageUrl.value = URL.createObjectURL(uploadFile.raw!)
}

const beforeAvatarUpload: UploadProps['beforeUpload'] = (rawFile) => {
  if (rawFile.type !== 'image/jpeg') {
    ElMessage.error('Avatar picture must be JPG format!')
    return false
  } else if (rawFile.size / 1024 / 1024 > 2) {
    ElMessage.error('Avatar picture size can not exceed 2MB!')
    return false
  }
  return true
}

const form = reactive({
  realname: '',
  position: '',
  phone: '',
  email: ''
})

const onSubmit = () => {
  let data = {
    realname: form.realname,
    position: form.position,
    phone: form.phone,
    email: form.email
  }
  boss.realname = form.realname
  boss.position = form.position
  boss.phone = form.phone
  boss.email = form.email
  fullDialogVisible.value = false
  updateBossInfo(data)
  console.log('submit!')
}

/* 公司认证 */
const centerDialogVisible1 = ref(false)
</script>

<style scoped>
/* 用户头像上传 */
.avatar-uploader .avatar {
  width: 178px;
  height: 178px;
  display: block;
}

.avatar-uploader .el-upload {
  border: 1px dashed red;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 1s;
}

.avatar-uploader .el-upload:hover {
  border-color: red;
}

.el-icon.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  text-align: center;
}

/* 名片设计 */
.card-wrap {
  height: 300px;
  background-image: url(./image.png);
  background-size: cover;
  box-shadow: 0 1px 3px 3px rgb(181, 181, 181);
  position: relative;
}

.card-wrap > span {
  display: inline-block;
  position: absolute;
}

.card-inner-font {
  font-weight: 500;
  font-size: 20px;
}

.card-wrap .card-name {
  top: 200px;
  left: 50px;
  font-weight: 600;
  font-size: 40px;
  letter-spacing: 10px;
}

.card-wrap .card-position {
  left: 50px;
  bottom: 40px;
}

.card-wrap .card-phone {
  left: 240px;
  top: 180px;
}

.card-wrap .card-address {
  left: 240px;
  top: 210px;
}

.card-wrap .card-email {
  left: 240px;
  top: 240px;
}

.card-tips {
  font-size: 12px;
  color: rgba(0, 0, 0, 0.5);
  font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
  font-weight: 500;
}

.page-box {
  background: url(https://static.shiyanlou.com/lanqiao/frontend/dist/img/page-bg.50c13e0.png)
    no-repeat;
  background-size: 100% auto;
  width: 100%;
  overflow: hidden;
}

.user-center-wrap {
  margin: 0 auto;
  padding-bottom: 20px;
  padding-top: 60px;
  width: 1200px;
}

/* 用户头部 */
.user-info-wrap {
  background: #fff;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  min-height: 146px;
  padding: 20px 40px 20px 20px;
  width: 1200px;
  box-sizing: border-box;
}

#editPost,
#Certification {
  background-color: RGB(227, 247, 246);
}

:is(#editPost, #Certification):hover {
  background-color: RGB(222, 236, 249);
}

/* left */
.user-info-wrap .left {
  flex: 1;
  position: relative;
}

.user-info-wrap .left .user-basic-info {
  display: flex;
  margin-bottom: 15px;
  padding-left: 90px;
  position: relative;
}

.user-avatar-link {
  display: inline-block;
  position: relative;
}

.user-info-wrap .left .user-basic-info .avatar {
  left: 0;
  position: absolute;
  top: -60px;
}

.user-avatar {
  padding: 0;
  transition: all 0.3s ease-in-out;
}

.user-avatar-image {
  border-radius: 50%;
  height: 100%;
  width: 100%;
}

.user-info-right > div {
  display: flex;
  justify-content: space-evenly;
  align-items: center;
}

.user-info-wrap .left .user-basic-info .user-info-right {
  font-size: 18px;
  font-weight: 500;
  margin-left: 20px;
}

.user-info-wrap .left .user-basic-info .user-info-right .name {
  color: #000;
  font-size: 22px;
  font-weight: 500;
  margin-right: 5px;
}

.user-info-wrap .left .user-basic-info .user-info-right .level {
  color: #ff8627;
  font-size: 22px;
  font-weight: 500;
  margin-right: 20px;
}

.basic-item:not(:last-child) {
  margin-right: 10px;
}

.basic-item {
  align-items: center;
  background: #edf5fe;
  border-radius: 14px;
  display: flex;
  padding: 4px 10px;
}

.basic-items .icon-name {
  height: 14px;
  width: 11px;
}

.basic-item .text {
  color: #000;
  font-size: 14px;
  font-weight: 400;
  margin-left: 4px;
}

.basic-items .icon-school {
  height: 12px;
  width: 14px;
}

.basic-items {
  align-items: center;
  bottom: 0;
  display: flex;
  left: 0;
  position: absolute;
}

/* right */
.user-info-wrap .right {
  display: flex;
  flex: 1;
  justify-content: flex-end;
}

/* 这里有点小问题的 */
.ext-items {
  align-items: center;
  display: flex;
}

.ext-items .cursor-pointer {
  cursor: pointer;
}

.ext-item {
  align-items: center;
  display: flex;
  flex-direction: column;
}

.ext-item .key {
  color: #000;
  font-size: 14px;
  font-weight: 400;
}

.ext-item .value {
  color: #000;
  font-size: 18px;
  font-weight: 500;
  margin-top: 9px;
}

.ext-items .divide {
  background: #000;
  height: 24px;
  margin: 0 39px;
  width: 1px;
}

/* 内容部分 */
.user-center-wrap .bottom-content {
  display: flex;
  justify-content: space-between;
  width: 100%;
}

/* 左侧 */
.user-center-wrap .bottom-content .left {
  width: 870px;
}

.card-panel {
  background: #fff;
  border-radius: 10px;
}

.mb-20px {
  margin-bottom: 20px;
}

.card-panel .header {
  padding: 20px 20px 23px;
  width: 100%;
}

.header-wrap {
  align-items: center;
  color: #666;
  display: flex;
  font-size: 14px;
  font-weight: 400;
  justify-content: space-between;
}

.header-wrap .title {
  color: #000;
  font-size: 20px;
  font-weight: 500;
  z-index: 2;
}

.content {
  height: 240px;
  padding: 0 20px 20px;
}

.card-panel {
  background: #fff;
  border-radius: 10px;
}

/* 右侧 */
.user-center-wrap .bottom-content .right {
  width: 310px;
}

.content .title {
  color: #000;
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 20px;
  padding-top: 20px;
  padding-left: 20px;
}

.content .visitors {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
}

.content .visitors .visitor-link {
  margin-bottom: 10px;
  width: 33.33%;
}

.content .visitors .visitor-link a {
  -webkit-text-decoration: none;
  text-decoration: none;
}

.font-normal {
  font-weight: 400;
}

.justify-center {
  display: flex;
  justify-content: center;
}

.flex {
  display: flex;
  flex-wrap: wrap;
}

.text-center {
  text-align: center !important;
}

.w-full {
  width: 100%;
}

.text-333 {
  --tw-text-opacity: 1;
  color: #333;
  color: rgba(51, 51, 51, var(--tw-text-opacity));
}

.text-center {
  text-align: center;
}

.text-xs {
  font-size: 0.75rem;
  line-height: 1rem;
}

.items-center {
  align-items: center;
}

.flex-col {
  flex-direction: column;
}

.name {
  display: inline-block;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 64px;
}

.timestamp {
  color: #898989;
}

.user-avatar-link {
  display: inline-block;
  position: relative;
}

.user-avatar {
  padding: 0;
  transition: all 0.3s ease-in-out;
}

.user-avatar-image {
  border-radius: 50%;
  height: 100%;
  width: 100%;
}

.vip-icon-container {
  bottom: 0;
  position: absolute;
  right: 0;
}
</style>
